package com.tangoj.model.enums;

/**
 * 判题状态枚举类
 */
public enum JudgeMessageEnum {

    SUCCESS(0,"判题成功"),
    FAIL(1,"判题失败"),
    Timeout(2,"运行超时"),
    Out_Of_Memory(3,"内存溢出"),
    Systematic_Error(4,"系统错误");

    final Integer state;
    final String message;

    JudgeMessageEnum(Integer state, String message) {
        this.state = state;
        this.message = message;
    }

    public Integer getState() {
        return state;
    }

    public String getMessage() {
        return message;
    }

    public static Integer getStateByMessage(String message){
        for (JudgeMessageEnum value : JudgeMessageEnum.values()) {
            if (value.getMessage().equals(message)){
                return value.getState();
            }

        }
        return null;
    }
}
